﻿@model IEnumerable<MasBank>

@{
    ViewBag.Title = "ธนาคาร";
    ViewBag.Descr = "ข้อมูลธนาคาร";
}

@using (Html.BeginForm("DeleteAll", "MasBank", FormMethod.Post, new { id = "form" }))
{
    @Html.AntiForgeryToken()
    
    <div class="row-fluid">    
        <div class="block-button-menu-above">
            @Html.ButtonAdd()
            @Html.ButtonDeleteAll()
        </div>

        @Html.ValidationSummary(true, "", new { @class = "alert alert-error" })

        <div class="row-fluid">
            <div class="table-header span12">
                <div class="span10">@ViewBag.Title</div>
				@Html.Partial("_ExportButton")
            </div>
        </div>

        <table id="table" class="table table-striped table-bordered table-hover" aria-describedby="table_info">
            <thead>
                <tr>
                    <th class="center" style="width:50px;">
                        <label>
                            <!-- Check box delete multiple records column-->
                            <input type="checkbox" />
                            <span class="lbl"></span>
                        </label>
                    </th>

                    <th>
                        ชื่อธนาคาร
                    </th>

                    <th>ชื่อธนาคารภาษาอังกฤษ</th>

                    <th class="center" style="width:80px;">
						<!-- Empty head column for export buttons -->
                    </th>
                </tr>
            </thead>

            <tbody>
                @foreach (var m in Model)
                {
                  <tr>
                    <td class="center">
                         <label>
                             <input type="checkbox" name="deleteIds" value="@(m.BankId)" />
                             <span class="lbl"></span>
                         </label>
                    </td>
                  
                      <td>@Html.DisplayFor(modelItem => m.Name)</td>
                      <td>@Html.DisplayFor(modelItem => m.NameEng)</td>
                          
                        <td class="td-actions">
                            <div class="hidden-phone visible-desktop btn-group">
                                @Html.ButtonDetails(new { Id = m.BankId }, true)
                                
                                @Html.ButtonEdit(new { Id = m.BankId }, true)

                                @Html.ButtonDelete(new { Id = m.BankId }, true)
                            </div>

                            <div class="hidden-desktop visible-phone">
                                <div class="inline position-relative">
                                    <button class="btn btn-minier btn-yellow dropdown-toggle" data-toggle="dropdown">
                                        <i class="icon-caret-down icon-only bigger-120"></i>
                                    </button>

                                    <ul class="dropdown-menu dropdown-icon-only dropdown-yellow pull-right dropdown-caret dropdown-close">
                                        <li>
                                            <a href="/MasBank/Details/@(m.BankId)" class="tooltip-gray" data-rel="tooltip" title="ดูรายละเอียด" data-placement="left">
                                                <span class="gray">
                                                    <i class="icon-search"></i>
                                                </span>
                                            </a>
                                        </li>

                                        <li>
                                            <a href="/MasBank/Edit/@(m.BankId)" class="tooltip-success" data-rel="tooltip" title="แก้ไข" data-placement="left">
                                                <span class="green">
                                                    <i class="icon-edit"></i>
                                                </span>
                                            </a>
                                        </li>

                                        <li>
                                            <a href="/MasBank/Delete/@(m.BankId)" class="tooltip-error" data-rel="tooltip" title="ลบ" data-placement="left">
                                                <span class="red">
                                                    <i class="icon-trash"></i>
                                                </span>
                                            </a>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </td>
                    </tr>
                }
            </tbody>
        </table>
    </div>
}

@section scripts {
	<script type="text/javascript">
	    $(function () {
	        var oTable1 = $('#table').dataTable({
	            "aoColumns": [
                    { "bSortable": false },
                    null,
                    null,
                    { "bSortable": false }
	            ]
	        });

	        $('table th input:checkbox').on('click', function () {
	            var that = this;
	            $(this).closest('table').find('tr > td:first-child input:checkbox')
				.each(function () {
				    this.checked = that.checked;
				    $(this).closest('tr').toggleClass('selected');
				});

	        });

	        $('[data-rel=tooltip]').tooltip();

	        $("form").submit(function () {
	            var currentForm = this;
	            bootbox.confirm(function (result) {
	                var _result = result;
	                if (result) {
	                    $.ajax({
	                        url: "DeleteAll",
	                        type: "post",
	                        dataType: "json",
	                        data: $(currentForm).serialize(),
	                        success: function (result) {
	                            if (result.success) {
	                                location.reload();
	                            } else {
	                            }
	                        }
	                    });
	                }
	            })
	            return false;
	        });
	    })

	</script>
}